<link rel="stylesheet" href="lib/ztree/3.5/css/zTreeStyle.css">
<link rel="stylesheet" href="lib/codemirror/4.1/lib/codemirror.css">
<link rel="stylesheet" href="app/solr/css/solr.css"/>

<div class="config_main">
    <div class="col-sm-2 config_left">
        <ul id="zkTree" class="ztree"></ul>
    </div>
    <div class="col-sm-10 config_right">
        <div style="margin-bottom: 10px;">
            <div class="pull-left">
                <button type="button" class="btn btn-default" ng-click="edit()" ng-show="!editMode">编辑</button>
                <button type="button" class="btn btn-primary" ng-click="save()" ng-show="editMode">保存</button>
                <button type="button" class="btn btn-danger" ng-click="confirmRemove()" ng-show="editMode">删除</button>
                <button type="button" class="btn btn-default" ng-click="cancel()" ng-show="editMode">取消</button>
                <img src="img/loading.gif" ng-show="save_loading" alt="Loading"/>
            </div>
            <div class="pull-right">
                <button type="button" class="btn btn-primary" ng-click="editUpload()">上传配置</button>
            </div>
            <div class="clearfix"></div>
        </div>

        <textarea id="config_code" name="config_code"></textarea>

        <div style="margin-top: 10px;">
            <button type="button" class="btn btn-default" ng-click="edit()" ng-show="!editMode">编辑</button>
            <button type="button" class="btn btn-primary" ng-click="save()" ng-show="editMode">保存</button>
            <button type="button" class="btn btn-danger" ng-click="confirmRemove()" ng-show="editMode">删除</button>
            <button type="button" class="btn btn-default" ng-click="cancel()" ng-show="editMode">取消</button>
            <img src="img/loading.gif" ng-show="save_loading" alt="Loading"/>
        </div>

    </div>
    <div class="clearfix"></div>
</div>

<!-- edit dialog -->
<div class="modal fade" id="uploadDialog" tabindex="-1">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h4 class="modal-title">上传配置</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" method="post" role="form">
                    <div id="uploadErrorMsg" class="alert alert-danger" ng-show="uploadErr">{{uploadErrMsg}}</div>
                    <div class="form-group">
                        <label for="upload_path" class="col-sm-2 control-label">配置路径</label>

                        <div class="col-sm-9">
                            <div class="input-group">
                                <span class="input-group-addon">/configs/</span>
                                <input type="text" class="form-control" id="upload_path" ng-model="upload_path" placeholder="相对路径">
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">配置文件</label>
                        <div class="col-sm-9">
                            <table style="width: 100%;">
                                <tr ng-repeat="(fileKey, uploadFile) in uploadFileMap">
                                    <td style="width: 90%;padding: 5px 0;">
                                        <input type="file" class="form-control" onchange="angular.element(this).scope().setUploadFile(event)" fileKey="{{fileKey}}"/>
                                    </td>
                                    <td>
                                        <a href="javascript:void(0)" ng-click="removeUploadFile(fileKey)">
                                            <span class="glyphicon glyphicon-minus" ></span>
                                        </a>
                                    </td>
                                </tr>
                            </table>
                            <div>
                                <a href="javascript:void(0)" ng-click="addUploadFile()">
                                    <span class="glyphicon glyphicon-plus"></span>
                                </a>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" ng-click="upload()">保存</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
            </div>
        </div>
    </div>
</div>

<!-- delete dialog -->
<div class="modal fade" id="removeDialog" tabindex="-1">
    <input type="hidden" id="removeId" ng-model="removeId" />
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h4 class="modal-title">删除确认</h4>
            </div>
            <div class="modal-body">
                <div class="alert alert-warning">您确认要删除吗。</div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-danger" ng-click="remove()">确认删除</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
            </div>
        </div>
    </div>
</div>